/*
 * @Author: hx 2542123711@QQ.com
 * @Date: 2024-11-26 18:17:14
 * @LastEditors: hx 2542123711@QQ.com
 * @LastEditTime: 2024-11-26 19:03:47
 * @FilePath: /class_process-signal/mykill.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include<sys/types.h>
#include<signal.h>
#include<unistd.h>
#include<cstring>

using namespace std;

//利用系统调用函数kill模拟命令行中的kill
int main(int argc, char* argv[])
{
    if(argc != 3)
    {
        cout << "Uasage: " << "   " <<endl;
        exit(1);
    }    

    int signo = stoi(argv[1]);
    int mypid = stoi(argv[2]);
    int n = kill(mypid, signo);
    if(n == -1)
    {
        cout << "kill error" <<endl;
        exit(2);
    }

    return 0;
}
